using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;

namespace Banshee.Winforms.Controls
{

    [ToolboxBitmap(typeof(Button))]
    [ToolboxItem("System.Windows.Forms.Design.AutoSizeToolboxItem,System.Design")]

    public class ProgressControl:Control
    {
        private Color _fillColor;
        
        public Color FillColor
        {
            get { return _fillColor; }
            set { _fillColor = value; }
        }
        private int _value;

        public int Value
        {
            get { return _value; }
            set
            {
                _value = value;
                this.Invalidate();
            }
        }
        public ProgressControl()
        {
            SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            UpdateStyles();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            DrawProgress(e.Graphics, _value);
        }
        void DrawProgress(Graphics g, int value)
        {
            //g.Clear(Color.Transparent);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            int w = this.Width / 100;
            int val = value * w;
            Rectangle rect = new Rectangle(0, 225, val, this.Height);
            g.FillRectangle(new SolidBrush(_fillColor), rect);
        }
        
    }
}
